<?php
class NewsApp extends CommonApp {
   
   	//最新揭晓
    public function indexAct(){
		$this->display();
    }

    //下拉刷新
    public function getnewAct(){
    	$page = My::arr2var($_GET,'page');
    	//最新揭晓
    	$result = DB('goods')->where("publish = '1'")->order("rate ASC")->limit(($page-1)*6,6)->clear()->select();
    	// foreach($result['rate'] as &$value){
    	// 	$value['params'] = My::decodeJson($value['params']);
    	// }
    	$html2 = $html = '';
    	if($result){
    		foreach($result as & $value){
	    		$value['image'] = !empty($value['image']) ? My::thums($value['image'],400,400,true) : My::thums('share/images/default.jpg',400,400,true);
	    		//揭晓时间已过
	    		if(strtotime($value['rate'])<=strtotime(date("Y-m-d H:i:s"))){
	    			$html2 .=<<<HTML
	    			<li class="i_li">
						<a href="index.php?app=Goods&act=detail&id={$value['id']}">
							<div class="img_inner">
								<img src="{$value['image']}">
							</div>
							<div class="deps prev newdeps">
								<img src="{$value['image']}" alt="">
								<p><span class="get">终于等到你</span></p>
								
								<p><i>15</i>人次获得</p>
							</div>
							<div class="deps prev noleft">
								<p>幸运云购码：10005600</p>
								<p>揭晓时间：3分钟前</p>
							</div>
						</a>
					</li>
HTML;
	    		}else{
	    			$html .= <<<HTML
	    		<li class="i_li">
					<a href="index.php?app=Goods&act=detail&id={$value['id']}">
						<div class="img_inner">
							<img src="{$value['image']}">
						</div>
						<p class="i_txt">{$value['title']}</p>
						<div class="countdown">
							<div class="price">价值：￥{$value['price']}</div>
							<span class="c_item">揭晓倒计时</span>
							<div class="hms count_down" count-down="{'endTime':'{$value['rate']}','stopTips':'00:00:00'}"></div>
						</div>	
					</a>
				</li>
HTML;
	    		}
    		}
    		$html = $html.$html2;
    		$html = Router::getInstance()->encodeUrls($html);
			$this->ajaxReturn('200',$html);
		}else $this->ajaxReturn('300',$html);
    }
   
}